package com.anuyun.ms.ums.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.anuyun.ms.ums.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

@Mapper
public interface UserDao extends BaseMapper<User>{
	

	
	
	/**
	 * 用户名查询
	 * @param userName
	 * @return
	 */
	@Select("select * from user where user_name = #{userName}")
	User getByUserName(String userName);
	
	

	

	
	/**
	 * 更新基本信息
	 * @param user
	 * @return
	 */
	@Update("update user set name = #{name},company = #{company},email=#{email},profession=#{profession},"
			+ "residence = #{residence} where id = #{id}")
	boolean updateInfo(User user);
	
	
	/**
	 * 更新登录信息
	 * @param user
	 * @return
	 */
	@Update("update user set last_error_time = #{lastErrorTime},error_times = #{errorTimes},locked=#{locked} where id = #{id}")
	boolean updateLoginInfo(User user);
	
	/**
	 * 修改密码
	 * @param user
	 * @return
	 */
	@Update("update user set password = #{password} where id = #{id}")
	boolean updatePassword(User user);
	
	/**
	 * 验证用户
	 * @param userName
	 * @param password
	 * @return
	 */
	@Select("select count(1) from user where user_name = #{userName} and password =#{password}")
	int login(@Param("userName") String userName ,@Param("password") String password);
	
	
}
